<template>
   <!-- 底部导航 -->
   <view class="tabbar" :style="{'padding-bottom': paddingBottomHeight + 'rpx'}">
      <view class="tabbar-item" v-for="(item, index) in list" :key="index" @click="tabbarChange(item.path)">
         <image class="item-img" :src="item.iconPath" v-if="current == index"></image>
         <image class="item-img1" :src="item.icon" v-else></image>
      </view>
   </view>
</template>
 
<script>
   export default {
      props: {
         current: String
      },
      data() {
         return {
            paddingBottomHeight: 0, //苹果X以上手机底部适配高度
            list: [{
                  text: '首页', //首页
                  icon: '/static/images/home1.png', //未选中图标
                  iconPath: '/static/images/home-active1.png', //选中图片
                  path: "/pages/index/index", //页面路径
               },
               {
                  text: '市场', //市场
                  icon: '/static/images/assets1.png',
                  iconPath: 'static/images/assets-active1.png',
                  path: "/pages/market/index/index",
               },
               {
                  text: '我的', //我的
                  icon: '/static/images/user1.png',
                  iconPath: '/static/images/user-active1.png',
                  path: "/pages/user/index",
               }
            ]
         };
      },
      created() {
         let that = this;
         uni.getSystemInfo({
            success: function(res) {
               let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
               model.forEach(item => {
                  //适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
                  if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
                     that.paddingBottomHeight = 40;
                  }
               })
            }
         });
      },
      watch: {
 
      },
      methods: {
         tabbarChange(path) {
            uni.switchTab({
               url: path
            })
         }
      }
   };
</script>
 
<style scoped>
   .tabbarActive {
      color: #79D5AD !important;
   }
 
   .tabbar {
      position: fixed;
      bottom: 48rpx;
      left: 45rpx;
      right: 30rpx;
      display: flex;
      justify-content: space-around;
      align-items: center;
      width: 600rpx;
      height: 126rpx;
      border-radius: 100rpx;
      background-color: #1fb3f7;
      padding: 0 30rpx;
			z-index: 99;
   }
 
   .tabbar-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100rpx;
   }
   
   /* 选中后 */
   .item-img {
      width: 50rpx;
      height: 50rpx;
      border-radius: 50%;
      box-shadow: 0rpx 0rpx 10rpx 10rpx #EEEFF0;
   }
   
   /* 选中前 */
   .item-img1 {
      width: 50rpx;
      height: 50rpx;
   }
 
</style>